package web.sso.common.tuple;

import web.sso.common.throwable.ConstructorNotAvailableError;

/**
 * DATE: 2020/1/19
 * TIME: 4:34 下午
 *
 * @author：huangliming
 */
public class Tuples {

    /**
     * 构造器不允许调用
     * 抛出异常的目的是防止反射调用
     */
    private Tuples() {
        throw new ConstructorNotAvailableError(Tuples.class);
    }

    /**
     * 创建一个包含两个元素的元组
     * @return
     */
    public static <T1, T2> Tuple2<T1, T2> of(
            T1 t1, T2 t2
    ) {
        return new Tuple2<>(t1, t2);
    }

    /**
     * 创建一个包含三个元素的元组
     * @return
     */
    public static <T1, T2, T3> Tuple3<T1, T2, T3> of(
            T1 t1, T2 t2, T3 t3
    ) {
        return new Tuple3<>(t1, t2, t3);
    }

    /**
     * 创建一个包含四个元素的元组
     * @return
     */
    public static <T1, T2, T3, T4> Tuple4<T1, T2, T3, T4> of(
            T1 t1, T2 t2, T3 t3, T4 t4
    ) {
        return new Tuple4<>(t1, t2, t3, t4);
    }

    /**
     * 创建一个包含五个元素的元组
     * @return
     */
    public static <T1, T2, T3, T4, T5> Tuple5<T1, T2, T3, T4, T5> of(
            T1 t1, T2 t2, T3 t3, T4 t4,
            T5 t5
    ) {
        return new Tuple5<>(t1, t2, t3, t4, t5);
    }

    /**
     * 创建一个包含6个元素的元组
     * @return
     */
    public static <T1, T2, T3, T4, T5, T6> Tuple6<T1, T2, T3, T4, T5, T6> of(
            T1 t1, T2 t2, T3 t3, T4 t4,
            T5 t5, T6 t6
    ) {
        return new Tuple6<>(t1, t2, t3, t4, t5, t6);
    }

    /**
     * 创建一个包含7个元素的元组
     * @return
     */
    public static <T1, T2, T3, T4, T5, T6, T7> Tuple7<T1, T2, T3, T4, T5, T6, T7> of(
            T1 t1, T2 t2, T3 t3, T4 t4,
            T5 t5, T6 t6, T7 t7
    ) {
        return new Tuple7<>(t1, t2, t3, t4, t5, t6, t7);
    }

    /**
     * 创建一个包含8个元素的元组
     * @return
     */
    public static <T1, T2, T3, T4, T5, T6, T7, T8> Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> of(
            T1 t1, T2 t2, T3 t3, T4 t4,
            T5 t5, T6 t6, T7 t7, T8 t8
    ) {
        return new Tuple8<>(t1, t2, t3, t4, t5, t6, t7, t8);
    }
}
